<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 400px;
            height: 300px;
            border: 1px solid black;
            margin: 0 auto;
        }

        img {
            width: 100%;
            height: 100%;
        }
    </style>
</head>

<body>
    <div>
        <img src="./imgs/timthumb (1).jpg" alt="" srcset="" class="pic">
    </div>
    <script>
        let data = [
            { imgsrc: 'imgs/timthumb (1).jpg' },
            { imgsrc: 'imgs/timthumb (2).jpg' },
            { imgsrc: 'imgs/timthumb (3).jpg' },
            { imgsrc: 'imgs/timthumb (4).jpg' },
        ]
        let pic = document.querySelector('.pic')
        let i = 0
        let timer = setInterval(() => {
            i++
            pic.src = data[i % data.length].imgsrc
        }, 1000);

    </script>
</body>

</html>